﻿//首页广告和banner
$(function(){
	
	/*活动专区特效*/
$(document).ready(function(){
	//环境
	if(document.getElementById("con_1")){
	var scrollPic_01 = new ScrollPic();
    scrollPic_01.scrollContId   = "con_1"; //内容容器ID
	scrollPic_01.arrLeftId      = "l_con_1";//左箭头ID
	scrollPic_01.arrRightId     = "r_con_1"; //右箭头ID
    scrollPic_01.frameWidth     = 244;//显示框宽度
    scrollPic_01.pageWidth      = 245; //翻页宽度
    scrollPic_01.speed          = 20; //移动速度(单位毫秒，越小越快)
    scrollPic_01.space          = 20; //每次移动像素(单位px，越大越快)
    scrollPic_01.autoPlay       = false; //自动播放
    scrollPic_01.autoPlayTime   = 0;
    scrollPic_01.initialize(); //初始化
	function autogun1(){
		scrollPic_01.rightMouseDown();scrollPic_01.leftEnd();
	}
	setInterval(autogun1,3000); //如果需要自动切换就这里不要注释就好
	if (window.ActiveXObject){
		$("#con_1").children("div").children("div").css("float",'left');
	}
	}
});	
/*导航切换*/	

	$(".nav-ul li a").wrapInner( '<span class="out"></span>' );
	
	$(".nav-ul li a").each(function() {
		$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
	});

	$(".nav-ul li a").hover(function() {
		$(".out",	this).stop().animate({'top':	'43px'},	300); // move down - hide
		$(".over",	this).stop().animate({'top':	'0px'},		300); // move down - show

	}, function() {
		$(".out",	this).stop().animate({'top':	'0px'},		300); // move up - show
		$(".over",	this).stop().animate({'top':	'-43px'},	300); // move up - hide
	});	
	
});

//玫瑰整形权威专家
if($("div").hasClass("main2-r1-c")){       
	
	$(".main2-r1-c ul li").hover(function(){
		$(".main2-r1-c ul li").children("span").stop(false,true).eq($(this).index()).animate({bottom:'0px'},500);
	},function(){
		$(".main2-r1-c ul li").children("span").stop(false,true).eq($(this).index()).animate({bottom:'-88px'},500);
	});
}

//首页幻灯片按钮显示隐藏
	$(".fx_banner_common").hide();
			$(".ic_content").hover(function(){
				$(".fx_banner_common").stop().fadeIn();
				},function(){
				$(".fx_banner_common").fadeOut();					
		})
					
	//////////////////////

if(document.getElementById('banner')){

	var _banner = $("#banner-t li");
	
	var _list = '';
	for(var _i = 0; _i < _banner.length; _i++){
		if(_i == 0){
			_list += '<li class="on"><a href="javascript:void(0)">'+(_i+1)+'</a></li>'; 
		}else{
			_list += '<li><a href="javascript:void(0)">'+(_i+1)+'</a></li>'; 
		}
	}
	var _m = document.createElement('div');
	_m.className = 'banner-m';
	_m.style.zIndex = '10';
	_m.innerHTML = ['<ul id="banner-m">',_list,'</ul>'].join('');
	document.getElementById('banner').appendChild(_m);
	delete _m;
	for(var _i = 0; _i < _banner.length; _i++){
		if(_i == 0){
			_banner[_i].style.zIndex = '2';
			_banner[_i].style.opacity = '1';
		}else{
			_banner[_i].style.zIndex = '0';
			_banner[_i].style.opacity = '0';
		}
	}
	
	var _mli = document.getElementById('banner-m').getElementsByTagName('li');
	for(var _i = 0; _i < _banner.length; _i ++){
		_mli[_i].index = _i;
		_mli[_i].onclick = function(){     //鼠标点击
			if(_banner.is(":animated")==false){
				var _this = this.index;
				var _s = '';

				for(var _j = 0; _j < _banner.length; _j++){
					if(_banner[_j].style.zIndex == '2'){
						_s = _j;break;
					};
				}
				
				if(_s != _this){
					
					for(var _j = 0; _j < _banner.length; _j++){
						_mli[_j].className = '';
					}
					_mli[_this].className = 'on';
					
					_banner[_this].style.zIndex = '1';
					_banner.eq(_s).animate({opacity:'0'},300,function(){
						$(this).css({"z-index":"0"});
						_banner.eq(_this).css("z-index","2");
					});
					_banner.eq(_this).animate({opacity:'1'},300);
				}
			}
		}
	}
	
	function autoPlay(){
		var _d = '', _s = '';

		for(var _j = 0; _j < _banner.length; _j++){
			if(_banner[_j].style.zIndex == '2'){
				_s = _j;
				if(_j == (_banner.length-1)){_d = 0;}else{_d = _j+1;}
				break;
			};
		}

		for(var _j = 0; _j < _banner.length; _j++){
			_mli[_j].className = '';
		}
		_mli[_d].className = 'on';
				
		_banner[_d].style.zIndex = '1';
		_banner.eq(_s).animate({opacity:'0'},300,function(){
			$(this).css({"z-index":"0"});
			_banner.eq(_d).css("z-index","2");
		});
		_banner.eq(_d).animate({opacity:'1'},300);
	}
	
	var _n = setInterval(autoPlay, 5000);
	
	$("#banner").hover(function(){
		clearInterval(_n);
		_n = false;
	},function(){
		if(!_n)_n = setInterval(autoPlay, 5000);
	});
}

//首页预约成功效果
$(function(){
	if(document.getElementById('main2-l2-c'))
	{
		var _ul = $("#main2-l2-c").children('ul');
		function autoScroll(){
			_ul.animate({marginTop:'-30px'},300,function(){
				$(this).children('li').eq(0).remove().appendTo($(this));
				$(this).css('margin-top','0px');
			});
		}
		var _auto = setInterval(autoScroll,2000);
		$("#main2-l2-c").hover(function(){
			clearInterval(_auto);
		},function(){
			_auto = setInterval(autoScroll,2000);
		});
	}
	
	if(document.getElementById('nowyy') && document.getElementById('lastyy')){
		
		var newD = new Date();
		document.getElementById('nowyy').innerHTML = 50 + parseInt(newD.getSeconds()); 
			
		document.getElementById('lastyy').innerHTML = 60 - parseInt(newD.getSeconds());
		
		setInterval(function(){
			var newD = new Date();
			document.getElementById('nowyy').innerHTML = 50 + parseInt(newD.getSeconds()); 
			
			document.getElementById('lastyy').innerHTML = 60 - parseInt(newD.getSeconds());
		},20000);
	}
})


//首页活动专区效果
if(document.getElementById('hotspot-r-c')){
	var _l = document.getElementById('hotspot-r-c').getElementsByTagName('ul')[0].getElementsByTagName('li').length;
	
	var _m = document.createElement('div');
	
}

//首页商务通效果
if(document.getElementById('swt-right-index')){
	$("#swt-right-index ul li").hover(function(){
		$(this).children("a").addClass("swt-hover");
		$(this).stop().animate({right:"84px"},200);
	
	},function(){
		$(this).animate({right:"0px"},200,function(){
			$(this).stop().children("a").removeClass("swt-hover");
		});
	});
}

//首页菜单动态调整位置
function posTop(obj) {
	var Top = 0;
	while (obj) {
		Top += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return parseInt(Top);
}
var _menudiv = document.getElementById('submenu').getElementsByTagName('div');

window.onscroll = function(){
	
	if(parseInt(document.documentElement.scrollTop || document.body.scrollTop) > posTop(document.getElementById('nav')) + 43){	

		$(".nav-submenu-xl").css("top",(parseInt(document.documentElement.scrollTop || document.body.scrollTop) - posTop(document.getElementById('submenu'))+43)+"px");
	}else{
		$(".nav-submenu-xl").css("top","43px");
	}
}

//首页导航效果
if(document.getElementById("submenu")){
var _submenu = $("#submenu").find('.submenu1');
var _time = 100;

function autoScrollDown(){
	if($(".nav-submenu").css("height") == '0px'){
		if(!-[1,] && !window.XMLHttpRequest){
			$(".nav-submenu").css("height","420px").find('.submenu1').eq(0).animate({top:'0px'},_time,function(){
				_submenu.eq(1).css("top","0px").animate({top:'105px'},_time,function(){
					_submenu.eq(2).css("top","105px").animate({top:'210px'},_time,function(){
						_submenu.eq(3).css("top","210px").animate({top:'315px'},_time);
					})
				});
			});
		}else{
			$(".nav-submenu").css("height","420px").find('.submenu1').eq(0).animate({bottom:'-105px'},_time,function(){
				_submenu.eq(1).css("bottom","-105px").animate({bottom:'-210px'},_time,function(){
					_submenu.eq(2).css("bottom","-210px").animate({bottom:'-315px'},_time,function(){
						_submenu.eq(3).css("bottom","-315px").animate({bottom:'-420px'},_time);
					})
				});
			
			});
		}
	}
}

function autoScrollUp(){
	$(".nav-l").removeClass("nav-l-hover");
	$(".nav-submenu").css("height","0px").find('.submenu1').stop().css("bottom","0px");
	$(".nav-submenu-xl").hide().children('div').hide();
	_submenu.removeClass('submenu1-hover');
}

$(".nav-l").hover(function(){

	clearTimeout(_autoscroll);
	$(".nav-l").addClass("nav-l-hover");
	autoScrollDown();
},function(){
	autoScrollUp();
});

var _autoscroll = setTimeout(function(){autoScrollUp();},5000);

$(function(){
	$(".nav-l").addClass("nav-l-hover");
	autoScrollDown();
}); 

_submenu.hover(function(){
	_submenu.removeClass('submenu1-hover').eq($(this).index()).addClass('submenu1-hover');
	$(".nav-submenu-xl").show().children('div').hide().eq($(this).index()).show();
	
});
}


/*新品推荐*/
$(function(){
	$("#safety_left a").hover(function(){
		
		$(this).children(".safelicon").stop().animate({top:"0px"},100);
		$(this).find(".st_hs").hide();
	},function(){
		$(this).children(".safelicon").stop().animate({top:"135px"},100);
		$(this).find(".st_hs").show();
	});
/*安全标准*/

	$("#safety_right_conr ul li").hover(function(){
		
		var _index = $(this).index();
		
		$("#safety_right_conr ul li").removeClass('safety_hli').eq(_index).addClass('safety_hli');
		
		for(var _i = 0; _i < 6; _i++){
			if(_i != _index){
				$("#safety_right_conl").children('div').children('span').eq(_i).css('bottom','-68px');
			}
		}
		
		$("#safety_right_conl").children('div').hide().eq(_index).show().children('span').stop(true,false).animate({bottom:'0px'},500);
	});
})

